/**
 * @author Phuc "Noel" Vo
 */
package com.example.noelwhereismystuffs.models;

import android.content.Context;

public class RegisterModel implements IRegisterModel {
	private static Database myData;
	private BackEndDatabase myDatabase;
	private Context myContext;

	public RegisterModel(Context context) {
		// myData = new Database();
		myContext = context;
		myDatabase = new BackEndDatabase(myContext);
	}

	@Override
	public void register(String username, String email, String password) {
		// myData.addUser(username, email, password);
		/**
		 * Add new User to the database
		 * 
		 * @param username
		 * @param email
		 * @param password
		 */
		myDatabase.open();
		myDatabase.addUser(username, email, password);
		myDatabase.close();
	}

	@Override
	public User getUser(String email) {
		myDatabase.open();
		String[] data = myDatabase.getUser(email);
		myDatabase.close();
//		return myData.getUser(email);
		return new User(data[0], data[1]);
	}

}
